/**
 * 
 */
package com.kclmedu.forhelp.filter;

import java.io.File;

import javax.swing.filechooser.FileFilter;

/**
 * Excel文件过滤器
 * @author yejf
 *
 */
public class ExcelFileFilter extends FileFilter {

	private static final String EXCEL_2003 = ".xls";
	private static final String EXCEL_2007 = ".xlsx";
	
	/* (non-Javadoc)
	 * @see java.io.FileFilter#accept(java.io.File)
	 */
	@Override
	public boolean accept(File pathname) {
		if(pathname.isDirectory()) {
			return true;
		}
		String fileName = pathname.getName().toLowerCase();
		if(fileName.endsWith(EXCEL_2003)) {
			return true;
		}
		if(fileName.endsWith(EXCEL_2007)) {
			return true;
		}
		//以上都不是，返回false
		return false;
	}

	@Override
	public String getDescription() {
		//
		return "*.xls;*.xlsx";
	}

}
